<?php
class Presupuesto extends AppModel {
    var $name = 'Presupuesto';
    public $actsAs = array('Search.Searchable');
    public $filterArgs = array(
            array('name' => 'empresa', 'type' => 'like', 'method' => 'findByOI', 'field' => 'OrdenInspeccion.empresa'));

    var $order = 'Presupuesto.fecha desc';
    
    public function findByOI($data = array()) {
			$this->OrdenInspeccion->Behaviors->attach('Containable', array('autoFields' => false));
			$this->OrdenInspeccion->Behaviors->attach('Search.Searchable');
			$query = $this->OrdenInspeccion->getQuery('all', array(
				'conditions' => array('OrdenInspeccion.empresa'  => $data['empresa']),
				'fields' => array('foreign_key')
			));
			return $query;
		}
    //The Associations below have been created with all possible keys, those that are not needed can be removed

    var $belongsTo = array(
            'Encargado' => array(
                            'className' => 'Encargado',
                            'foreignKey' => 'encargado_id',
                            'conditions' => '',
                            'fields' => '',
                            'order' => ''
            ),
            'OrdenInspeccion' => array(
                            'className' => 'OrdenInspeccion',
                            'foreignKey' => 'orden_inspeccion_id',
                            'conditions' => '',
                            'fields' => '',
                            'order' => ''
            )
    );



    var $hasMany = array(
            'PresupuestoDetalle' => array(
                            'className' => 'PresupuestoDetalle',
                            'foreignKey' => 'presupuesto_id',
                            'dependent' => false,
                            'conditions' => '',
                            'fields' => '',
                            'order' => '',
                            'limit' => '',
                            'offset' => '',
                            'exclusive' => '',
                            'finderQuery' => '',
                            'counterQuery' => ''
            )
    );

}
?>